<template>
	<yd-layout id='bdStageList' class=''>
		<yd-infinitescroll v-show="examList.length>0" :callback="getHistory" ref="infinitescrollDemo">

			<div slot="list"  @click="goBd_result(item)" class="list" v-for="item,index in examList">
				<div class="list_label" :style="{background:item.status ==1?'#DCBBC9':'#FE5742'}">{{item.status ==1?'已通过':'未通过'}}</div>
				<div class="title c_size_34_48">测评得分：{{item.real_score}}</div>
				<div class="list_bottom">
					<div class="list_num">第{{item.times}}次测评</div>
					<div class="list_time">{{item.newTime}}</div>
				</div>
			</div>
			<!-- 数据全部加载完毕显示 -->
			<span slot="doneTip">没有更多数据了~~</span>

			<!-- 加载中提示，不指定，将显示默认加载中图标 -->
			<!--<img slot="loadingTip" src="path/img/loading.svg"/>-->
		</yd-infinitescroll>
		<NoList v-show='examList.length==0'>
			<img slot='img' src="../../../assets/kong_2.png" alt="" />
		</NoList>
		
		<yd-backtop></yd-backtop>
		
	</yd-layout>
</template>

<script>
	import { InfiniteScroll } from 'vue-ydui/dist/lib.rem/infinitescroll';
	import { BackTop } from 'vue-ydui/dist/lib.rem/backtop';
	export default{
		components:{
			[InfiniteScroll.name]: InfiniteScroll,
			[BackTop.name]: BackTop,
		},
		data(){
			return {
				examList:[],
				pageNum: 1,
				pageCount: 10,
			}
		},
		created() {
		},
		watch: {
			
		},
		computed: {
			
		},
		mounted(){
			document.title='测评记录'
			this.getHistory()
		},
		methods:{
			getHistory(){
				this.$root.ajax({
					name:'bible/history',
					type:'get',
					params:{
						page: this.pageNum,
						count: this.pageCount,
						level_id:this.$route.query.level_id
					}
				}).then((d)=>{
					for(let a = 0 ;a<d.data.exam_list.length;a++){
						d.data.exam_list[a].newTime = this.$root.getDate(new Date(d.data.exam_list[a].create_time*1000))
					}
					this.examList = [...this.examList, ...d.data.exam_list];
					
					if(this.examList.length >= d.data.exam_total) {
						/* 所有数据加载完毕 */
						this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.loadedDone');
						return;
					}

					/* 单次请求数据完毕 */
					this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.finishLoad');

					this.pageNum++;
				})
			},
			goBd_result(item){
				this.$router.push({
					name:'bd_result',
					query:{
						exam_id:item.id
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	@import './stageList.scss';
</style>